package com.goldgov.route.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.goldgov.route.service.RouteRule;
import com.goldgov.route.service.RouteRuleService;
import com.goldgov.route.service.ServiceVersion;

@RestController
@RequestMapping("route")
public class RouteRuleController {

	@Autowired
	private RouteRuleService routeRuleService;
	
	@PostMapping
	public void addRouteRule(RouteRule routeRule) {
		routeRuleService.addRouteRule(routeRule);
	}
	
	@PostMapping("select")
	public void selectRouteRule(RouteRule routeRule) {
		routeRuleService.addRouteRule(routeRule);
	}
	
	@PutMapping
	public void updateRouteRule(RouteRule routeRule) {
		routeRuleService.updateRouteRule(routeRule);
	}
	
	@DeleteMapping
	public void deleteRouteRule(String[] ids) {
		routeRuleService.deleteRouteRule(ids);
	}
	
	@GetMapping("/{ruleID}")
	public RouteRule getRouteRule(@PathVariable("ruleID") String ruleID) {
		return routeRuleService.getRouteRule(ruleID);
	}

	@GetMapping("/project/{projectID}")
	public List<RouteRule> listRouteRuleByPorject(@PathVariable("projectID") String projectID) {
		return routeRuleService.listRouteRuleByPorject(projectID);
	}
	
	@GetMapping
	public List<RouteRule> listRouteRule(String[] excludeIDs) {
		return routeRuleService.listRouteRule(excludeIDs);
	}
	
	@GetMapping("/version/{ruleID}")
	public List<ServiceVersion> listVersion(@PathVariable("ruleID") String ruleID) {
		return routeRuleService.listVersion(ruleID);
	}
}
